package threading;

public class ThreadDemo16 {
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
                    try {
                        System.out.println("wait 开始");
                        synchronized (locker) {
                            locker.wait();
                        }
                        System.out.println("wait 结束");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
        });
        t1.start();
        Thread.sleep(1000);

        Thread t2 = new Thread(() -> {
            synchronized(locker) {
                System.out.println("notify 开始");
                locker.notify();
                System.out.println("notify 结束");
            }
        });
        t2.start();

    }
}
